import React from 'react';
import { Router, Route, Switch } from 'dva/router';
import dynamic from 'dva/dynamic';
import { LocaleProvider } from 'antd';
import zh_CN from 'antd/lib/locale-provider/zh_CN';
import 'moment/locale/zh-cn';

const routes = [{
    path: '/' ,
    models: () => [import('./models/example')],
    component: () => import('./routes/login/Login'),
},
{//登录页面
    path: '/login',
    models: () => [import('./models/example')],
    component: () => import('./routes/login/Login'),
},
{//管控页面主体
    path: '/controlSubject/*',
    models: () => [import('./models/example')],
    component: () => import('./routes/controlPlatform/controlSubject'),
},
    {//驾驶舱
        path: '/cockpit',
        models: () => [import('./models/example')],
        component: () => import('./routes/cockpit/indexPage'),
    }
];

function RouterConfig({ history, app }) {
    return (
        <LocaleProvider locale={zh_CN}>
        <Router history={history}>
            <Switch>
                {
                    routes.map(({ path, ...dynamics }, key) => (
                        <Route
                            key={key}
                            exact
                            path={path}
                            component={dynamic({
                                app,
                                ...dynamics,
                            })}
                        />
                    ))
                }
            </Switch>
        </Router>
        </LocaleProvider>
    );
}

export default RouterConfig;
